folditfandomcom-20200222-history
Lua Functions That Should Be Implemented
This is a place to brainstorm and figure out what functions should be added to foldit by the foldit team to allow you to create scripts that imitate the actions that you perform as a human: Protein Manipulation Functions Threshold parameters, which automatically stops wiggle and shake when the score goes outside of a delta range. For example, do_global_wiggle_backbone(1,10,3) would perform the normal do_global_wiggle_backbone(1) operation, but would stop the wiggle if the score went down by 10 points or more, or up by 3 or more. If these parameters were nil, then foldit would perform the current functionality. Many scripts need to put the protein into a higher energy state to get them out of a local minimum, but not distort the protein structure excessively. One iteration frequently is too much change in the protein, which causes the current entire structure layout to be lost. We need the ability to tweak sheets and helices, with all of the operations available from the user interface. We need the ability to set the note for a segment of the protein. Banding Functions We need the ability to create bands with lengths greater than 20. This current restriction on bands vastly restricts some of the scripts that we can write, as it means that we can only create bands that apply outward pressure when the segments are within 20 units of each other. The maximum should be very large, at least larger than the maximum length between the ends of the protein. We need the ability to find the length of an existing band. We need the ability to find the segment numbers of the endpoints of a band. We need the ability to modify the strength and length of all existing bands, and affect all future created bands. We need the ability to band to a sidechain, not just the backbone. Bands to empty space We need the ability create a band that is attached to a segment on one side, but attached to empty space on the other. This is a difficult problem, as we also need the ability to figure out where to place the endpoint of the band to empty space. Heuristically this is almost always relative to another part of the structure. To create a band to empty space, you'd need spherical coordinates from a given segment. The tricky thing is establishing the frame of reference for the coordinate system for these spherical coordinates. Define the function to create the band like this: local bandNew = band_createtoempty(segmentOrigin, segmentXAxis, segmentYAxis, rho, theta, phi) * The X axis is defined as the line passing through segmentOrigin and segmentXAxis. * The Y axis defined by segmentOrigin, segmentXAxis, and segmentYAxis. These three arguments define a plane that passes through these three segments. The Y axis is perpendicular to the X axis in this plane, passing through segmentOrigin. * The Z axis is perpendicular to the X and Y axes, passing through segmentOrigin. The first three arguments are the segment numbers of segments in the protein. The segments segmentOrigin, segmentXAxis, and segmentYAxis must be different from one other. If these segments are in a straight line (likely to happen only in a De Novo protein or a sheet), the function would fail and return zero, otherwise it would return the band number of the new band. Once the three axes are defined, theta, and phi define the angles from these axes in radians. Rho defines the length in the same units used to measure the distance between segments. Most computer trig functions use radians. A simple conversion, shown in the example below, can convert from degrees to radians. The example below would create a band to empty space from segment 12, with rho of 20, a theta of 30, and a phi of 30. The angles would be relative to the coordinate system established from the segments numbered 12, 49, and 42 in the protein. local pi = 3.14159265358979323 local decToRad = pi / 180 local segmentOrigin = 12 local segmentXAxis = 49 local segmentYAxis = 42 local rho = 20 local theta = 30 * decToRad -- 30 degrees in radians local phi = 30 * decToRad -- 30 degrees in radians local bandNew = band_createtoempty(segmentOrigin, segmentXAxis, segmentYAxis, rho, theta, phi) if bandNew ~= 0 then print('Created band '..bandNew) else print('Band create failed') end It may be that implementing bands with lengths greater than 20 accomplishes the majority of the things people do with bands to empty space, so that should be implemented first. Freezing Functions We need the ability to find out what segments are currently frozen. We need the ability to unfreeze a single segment. Alignment Functions We need tools to manipulate the alignment tool. We need the ability to do "align guide". Investigative Functions We need a function to get the score of what is in the Recent Best save. This is especially important, because many operations performed by foldit perform transformations that affect the Recent Best without returning at that point. For example, if a do_global_wiggle_all(1) executes (particularly with a band in place), it is possible that the score may increase, which causes the Recent Best to be updated, then decrease again as the structure continues to change. The only points that our script can retrieve the current score is before and after the do_global_wiggle all(1), so there is no way to reliably know what the score is of the Recent Best. Our scripts must be considerably more complicated and inaccurate without this function. There is a way that can be used now that works, but as you can see it is extremely awkward and slow, plus it will flash the user interface: function GetScoreRecentBest() quicksave(10) restore_recent_best() local score = get_score() quickload(10) return score end We need functions that can find out which segments are currently selected. We need the get_score() function to be able to return negative scores. This can be done currently with the following function, but it awkward and slow: Done local function GetScore() local score = get_score() if score 0 then score = 8000 for i=1, get_segment_count() do score = score + get_segment_score(i) end end return score end We need the get_aa() to be implemented again, and return the id of an amino acid. Done We need the ability to find out the current user name. We need the ability to find out the current group name. We need the ability to find out our current solo and group rank. We need the ability to retrieve the entire group and solo rank lists to a lua table. This is important for a script trying to increase rank. If there is a 30 point difference between me and the person above me, a different part of the script may run than if there is .03 points between us. Also, some scripts may execute different strategies based on the score between me and the person in first place. We need the ability to find the name of the current puzzle (e.g. 317: Casp9 Puzzle 13) We need the ability to retrieve the date and time a puzzle was posted. We need the ability to retrieve the expiration date and time of a puzzle. As a puzzle gets near to the expiration time, a script might use different strategies than if there were more time. We need the ability to retrieve the date and time that a puzzle was first worked on. Early in the working on a puzzle, one might use a completely different strategy than later. We need the ability to retrieve the names of all the current saves for a given puzzle. We need the ability to find out where voids are located. This needs to happen in such a way that we can identify protein segments that are around the void. We need the ability to retrieve the note assigned to a segment of a protein. Other Functions We need the ability of a recipe to be able to call another recipe. We need at least one of these two features: * We need the ability to maintain a stack of savesets. A saveset here is defined as all of the quicksave slots, plus the recent best. We need a saveset_push() and saveset_pop() function. A saveset_push() would take the current savesets and copy them to the top of a stack. When a saveset_pop() occurs, the top of the stack would overwrite all of the current saveset slots. The purpose is to make parts of a complex script not have to worry about what slots have been used. So at the start of a function, it can call saveset_push(), and before it returns, it can call saveset_pop(). * We need the ability to save savesets by name. saveset_save('foo'), saveset_restore('foo'), would save and restore the current savesets to the name 'foo'. These do not have to be persisted across runs of a script. These could again be used to save a saveset at the beginning of a function and restore it at the end. Lua Functions Many of the Lua standard library functions need to be implemented. A discussion of which functions and their impact can be found at Lua Standard Libraries